




class Role():
    def __init__(self, user_name, attack, score):
        self.user_name=user_name
        self.blood=1000
        self.attack=attack
        self.score=score
        self.room="01"
    #展示基本信息
    def show(self):
        print(f"{self.user_name}初始血量为：{self.blood}点血，攻击力为：{self.attack}，初始积分为：{self.score},所在房间号为：{self.room}")
    #攻击方法
    def attack(self,target):
        while True:
            choice=input(f"{self.user_name}的选择是：1、查看当前信息\n 2、攻击\n 3、退出\n")
            if choice=="1":
                self.show()
            elif choice=="2":
                result=target.defend(self.attack)
                if result==0:
                    return False
                break
            elif choice=="3":
                return self.quit()
    def defend(self, injure):
        self.blood-=injure
        if self.blood<= 0:
            self.blood=0
            self.score=0
            print(f"{self.user_name}受到了{injure}点伤害后阵亡，积分为0，失去攻击资格，退出游戏")
            self.quit()
        else:
            self.score+=injure
            print(f"{self.user_name}受到了{injure}点伤害，剩余血量：{self.blood},当前积分为：{self.score}")
    #退出游戏
    def quit(self):
        return False
#创建实例
player1=Role("夏经纬",10,0)
player2=Role("周雨晴",10,0)
player1.attack(player2)